package com.dfbz.demo;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.SequenceInputStream;
import java.util.Enumeration;
import java.util.Vector;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo05_序列流 {

    public static void main(String[] args) throws Exception {

        FileInputStream fis_01 = new FileInputStream("01.txt");
        FileInputStream fis_02 = new FileInputStream("02.txt");
        FileInputStream fis_03 = new FileInputStream("03.txt");

        Vector<FileInputStream> vector = new Vector<>();
        vector.add(fis_01);
        vector.add(fis_02);
        vector.add(fis_03);

        Enumeration<FileInputStream> elements = vector.elements();

        SequenceInputStream sis = new SequenceInputStream(elements);
        FileOutputStream fos = new FileOutputStream("menus");

        int data;

        while ((data = sis.read()) != -1) {
            fos.write(data);
        }

        sis.close();
        fos.close();

    }

}
